﻿using System;
using System.Speech.Synthesis;
using System.IO;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;

namespace SkypieeClient
{
    public partial class AvatarInfo
    {
        Window1 w;
        Skypiee.Core.SkypieeUser user;
        public AvatarInfo(Window1 win, Skypiee.Core.SkypieeUser u)
        {
            this.InitializeComponent();
            w = win;
            user = u;

            UserControl.DataContext = user;
            
        }

        private void ButtonCancel_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            w.CheckBoxOnline.IsEnabled = true;
            w.TabControlMain.IsEnabled = true;
            w.MainGrid.Children.Remove(this);
        }

        private void ButtonChat_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            SKYPE4COMLib.IChat chat = w.SCore.skype.CreateChatWith(user.Handle);
            chat.OpenWindow();
        }


        private void ButtonStartCall_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            w.SCore.PlaceCall(user.Handle);
            SpeechSynthesizer synthesizer = new SpeechSynthesizer();
            PromptBuilder promptBuilder = new PromptBuilder();
            promptBuilder.StartStyle(new PromptStyle(PromptRate.Medium));
            promptBuilder.AppendText("Place call for " + user.Handle);
            promptBuilder.EndStyle();
            synthesizer.Speak(promptBuilder);
        }

        private void ButtonStopCall_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            foreach (SKYPE4COMLib.Call ic in w.SCore.skype.ActiveCalls)
            {
                if (ic.PartnerHandle == user.Handle)
                {
                    ic.Finish();
                    SpeechSynthesizer synthesizer = new SpeechSynthesizer();
                    PromptBuilder promptBuilder = new PromptBuilder();
                    promptBuilder.StartStyle(new PromptStyle(PromptRate.Medium));
                    promptBuilder.AppendText("Finish a call to " + user.Handle);
                    promptBuilder.EndStyle();
                    synthesizer.Speak(promptBuilder);
                }
            }
        }
    }
}